// index.js
Page({
  data: {
    isPlayingMusic: false
  },
  bgm: null,
  music_url: 'https://webfs.hw.kugou.com/202306041359/f2e0e38fefb04310f74e30c211839682/KGTX/CLTX001/fa715f44cf0bfb9c4e3a47084e643eff.mp3',
  music_coverImgUrl: 'https://www.kugou.com/album/info/17s94m30/',
  onReady: function() {
    // 创建getBackgroundAudioManager实例对象
    this.bgm = wx.getBackgroundAudioManager()
    // 音频标题
    this.bgm.title = 'Letting Go'
    // 专辑名称
    this.bgm.epname = '天赐的声音第四季 第4期'
    // 歌手名
    this.bgm.singer = 'singer'
    // 专辑封面
    this.bgm.coverImgUrl = this.music_coverImgUrl
    this.bgm.onCanplay(() => {
      this.bgm.pause()
    })
    // 指定音频的数据源
    this.bgm.src = this.music_url
  },
  // 播放器的单击事件
  play: function() {
    if (this.data.isPlayingMusic) {
      this.bgm.pause()
    } else {
      this.bgm.play()
    }
    this.setData({
      isPlayingMusic: !this.data.isPlayingMusic
    })
  },
  show:function(e){
    let id = e.currentTarget.dataset.id;
    console.log(id);
    wx.navigateTo({
      url: '/pages/show/show?id=' + id,
    }) 
  }
})
